package edm.qunar.com;

import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;

import org.apache.commons.lang.StringUtils;

public class ConfigUtils {

	private static Properties props = new Properties();
	static {

		try {
			// 读类路径下文件
			// props.load(JdbcUtils.class.getClassLoader().getResourceAsStream("jdbc.properties"));
			// 读包外文件
			props.load(new FileInputStream("jdbc.properties"));
		} catch (IOException e) {
			e.printStackTrace();
		}

	}

	public static String getValue(String key, String defaultValue) {

		String value;
		value = props.getProperty(key, defaultValue);

		return value;
	}

	public static int getIntValue(String key, String defaultValue) {

		String value;
		int v = Integer.valueOf(defaultValue);
		value = props.getProperty(key, defaultValue);

		if (StringUtils.isNumeric(value))
			v = Integer.valueOf(value);

		return v;

	}

	public static void main(String args[])  {

		System.out.println(getValue("22","haha"));
	}
}
